package com.group.project.hrms.service.impl;

import com.group.project.hrms.entity.AttendanceGroupDeptAdjustRecord;
import com.group.project.hrms.mapper.AttendanceGroupDeptAdjustRecordMapper;
import com.group.project.hrms.service.IAttendanceGroupDeptAdjustRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

@Service
public class AttendanceGroupDeptAdjustRecordService implements IAttendanceGroupDeptAdjustRecordService {

    @Autowired
    private AttendanceGroupDeptAdjustRecordMapper attendanceGroupDeptAdjustRecordMapper;

    @Override
    public int insertAttendanceGroupDeptAdjustRecord(AttendanceGroupDeptAdjustRecord attendanceGroupDeptAdjustRecord) {
        return attendanceGroupDeptAdjustRecordMapper.insert(attendanceGroupDeptAdjustRecord);
    }

    @Override
    public int deleteAttendanceGroupDeptAdjustRecord(AttendanceGroupDeptAdjustRecord attendanceGroupDeptAdjustRecord) {
        return attendanceGroupDeptAdjustRecordMapper.delete(attendanceGroupDeptAdjustRecord);
    }

    @Override
    public int updateAttendanceGroupDeptAdjustRecord(AttendanceGroupDeptAdjustRecord attendanceGroupDeptAdjustRecord) {
        return 0;
    }

    @Override
    public List<AttendanceGroupDeptAdjustRecord> selectAttendanceGroupDeptAdjustRecordByGroupID(String groupID) {
        Example example = new Example(AttendanceGroupDeptAdjustRecord.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.orEqualTo("attendanceGroupId" , groupID);
        return attendanceGroupDeptAdjustRecordMapper.selectByExample(example);
    }

    @Override
    public List<AttendanceGroupDeptAdjustRecord> selectAttendanceGroupDeptAdjustRecordByDeptID(Long deptID) {
        Example example = new Example(AttendanceGroupDeptAdjustRecord.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.orEqualTo("deptId" , deptID);
        return attendanceGroupDeptAdjustRecordMapper.selectByExample(example);
    }

    @Override
    public List<AttendanceGroupDeptAdjustRecord> selectAttendanceGroupDeptAdjustRecordByMonth(String month) { //月份的数据结构为：2022-04
        Example example = new Example(AttendanceGroupDeptAdjustRecord.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.orLike("cTime", "%" + month + "%");
        return attendanceGroupDeptAdjustRecordMapper.selectByExample(example);
    }

    @Override
    public List<AttendanceGroupDeptAdjustRecord> selectAllAttendanceGroupDeptAdjustRecord() {
        return null;
    }
}
